




export default {
	namespaced: true,
	state: {
		memberId: 0, //用户ID
		isLogin: false, // 登录状态
		account:'',//账号
		nickName: '', // 昵称
		avatar: '', // 默认头像
		userInfo:{},//用户的所有的详细信息
	},
	mutations: {
		'SET_USER_INFO'(state, payload){
			const {account,nickName,avatar,memberId} = payload
			state.account = account
			state.isLogin = true
			state.nickName = nickName
			state.avatar = avatar
			state.memberId = memberId
			state.userInfo = payload
			uni.setStorageSync("xgz:user", state);
		}
	},
	actions: {
		async login({state, commit, dispatch, rootState}, data) {
			const audit = data.user_audit_info.audit
		},
		
		async logout({state, rootState}) {
			for (let j in state) {
				state[j] = ''
			}
			state.isLogin = false;
			let statistics = rootState.statistics;
			for (let j in statistics) {
				for (let i in statistics[j]) {
					statistics[j][i] = 0
				}
			}
			// 从本地缓存中异步移除指定key
			uni.removeStorageSync('wanlshop:user');
			uni.removeStorageSync('wanlshop:statis');
		},
	}
};